package com.dckxx.controller;

import com.dckxx.common.vo.Result;
import com.dckxx.entity.ClassStudentEntity;
import com.dckxx.entity.StudentEntity;
import com.dckxx.service.IClassStudentService;
import com.dckxx.service.IStudentService;
import com.dckxx.vo.StudentVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("student")
public class StudentController {

    @Resource
    private IStudentService studentService;
    @Resource
    private IClassStudentService classStudentService;

    @GetMapping("list")
    public Result<?> getList(){
        List<StudentEntity> list = studentService.list();
        log.info("list:{}",list);
        return Result.ok(list);
    }

    @GetMapping("vo")
    public Result<?> getVO(){
        List<StudentEntity> list = studentService.list();
        StudentVO studentVO = new StudentVO();
        studentVO.setList(list);

        log.info("vo:{}",studentVO);
        return Result.ok(studentVO);
    }

    @GetMapping("table")
    public Result<?> getTable(){
        List<ClassStudentEntity> list = classStudentService.list();

        log.info("table:{}",list);
        return Result.ok(list);
    }
}
